package com.neuedu.his.controller;

import com.neuedu.his.po.Constanttype;
import com.neuedu.his.service.ConstanttypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/master/constant/type")
public class ConstantTypeController {

    @Autowired
    private ConstanttypeService constantTypeService;


    @GetMapping("/list")
    public List<Constanttype> list() {
        return constantTypeService.list();
    }


    @GetMapping("/getById/{id}")
    public Constanttype getById(@PathVariable Long id) {
        return constantTypeService.getById(id);
    }


    @PostMapping("/saveOrUpdate")
    public boolean saveOrUpdate(@RequestBody Constanttype constantType) {
        // 前端会传来 id（编辑）或无 id（新增）
        return constantTypeService.saveOrUpdate(constantType);
    }


    @DeleteMapping("/deleteById/{id}")
    public boolean deleteById(@PathVariable Long id) {
        return constantTypeService.removeById(id);
    }
}
